package com.galleryviewpager;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

import androidx.appcompat.widget.AppCompatImageView;

public class PolygonView extends AppCompatImageView {

    private int mWidth =0;
    private int mHeight =0;
    private Paint mPaint;
    private int mBorderWidth;
    private Paint mBorderPaint;

    public PolygonView(Context context) {
        super(context);
        init(context);
    }

    public PolygonView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context);
    }

    public PolygonView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context);
    }

    private void init(Context context) {
        mBorderWidth = DensityUtils.dip2px(context, 4);
        setLayerType(View.LAYER_TYPE_SOFTWARE,null); //关闭硬件加速器
        mPaint = new Paint();
        mPaint.setAntiAlias(true);
        mPaint.setColor(Color.RED);
        mPaint.setDither(true);

        mBorderPaint = new Paint();
        mBorderPaint.setColor(Color.WHITE);
    }
}
